<?php

use App\Http\Controllers\Web\Admin\UserController;
use App\Http\Controllers\Web\AuthController;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//免验证
Route::post('login', [AuthController::class, 'login'])->name('except.login');
Route::get('logout', function () {
    Auth::logout();
    return Response::noContent();
})->name('except.logout');

Route::get('/clear', function() {
    Artisan::call('cache:clear');
    Artisan::call('config:clear');
    Artisan::call('config:cache');
    Artisan::call('view:clear');
    return json_encode(['code' => 200, 'data' => [], 'message' => 'success']);
})->name('except.clear');

Route::middleware(['auth:sanctum'])->group(function () {
    Route::apiResource('user', 'Admin\\UserController')->only(['index', 'show']);
    Route::get('getMenuList', [UserController::class, 'getMenuList'])->name('user.get_menu_list');
    Route::get('getPermCode', [UserController::class, 'getPermCode'])->name('user.get_perm_code');
});

